/**
 * meiguang8.com
 * Copyright (C) 2016-2019 All Rights Reserved.
 */
package com.yuanchuang.yp.mall.web.admin.controller.user;

import com.yuanchuang.yp.framework.common.CommonResult;
import com.yuanchuang.yp.mall.web.admin.user.model.LoginModel;
import com.yuanchuang.yp.mall.web.admin.user.model.LoginRequest;
import com.yuanchuang.yp.mall.web.admin.user.service.AuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * class_name: AuthController
 * package: com.yuanchuang.yp.mall.web.admin.controller.auth
 * describe: TODO
 * @author: yuanyuan.zhu
 * creat_date: 2019/7/11
 * creat_time: 13:49
 **/
@Api(tags = {"登陆注册接口"})
@RestController
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    private AuthService authService;
    @ApiOperation( value = "用户登陆")
    @PostMapping("/token")
    public CommonResult<LoginModel> login(@RequestBody LoginRequest loginRequest) {
        try {
            LoginModel login = authService.login(loginRequest);
            return CommonResult.ok(login);
        } catch (Exception e) {
            return CommonResult.error(e.getMessage());
        }
    }

}
